﻿Imports OMANE.Common.UI
Imports System.Windows.Input
Imports OMANE.Common.Model.Interfaces
Imports PTIC_Util

Namespace ViewModels
    Public Class ViewModelGarantiesIncapInval
        Inherits ViewModelCommand
        Implements IViewModelTabSection

        Private _model As ModelTauxGarantis
        Public Property IsClosable As Boolean Implements IViewModelTabSection.IsClosable

        Public Sub New(ByVal Model As ModelTauxGarantis, ByVal DisplayName As String, ByVal Command As ICommand)
            MyBase.New(DisplayName, Command)
            _model = Model
            ViewModels.SegmentProvider.model = Model

            TablesBCAC = False

            _AbattementMaladiesNonObjectivables = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Tx_abat_MalaNonObje.Nom, _
              "Abattement exclusion maladies non obectivables")

            _AbattementExclusionPerteRevenus = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Tx_abat_ExclPerteRev.Nom, _
              "Abattement exclusion perte de revenus")

            _AgeFinGarantiesIncapInvalSegmente = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Age_FinINCINV.Nom, _
              "Age de fin de la garantie INCAP/INVAL")

            _MajorationPrudentielle = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Tx_MajoPrudSinINCINV.Nom, _
              "Majoration prudentielle des montants de sinistres INCAP/INVAL")

            _ChargementDeSecurite = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Tx_chgtSecuINCINV.Nom, _
              "Chargement de sécurité lié aux incertitudes sur la table INCAP/INVAL")

            _TauxMensuelEntreeEnIncapacite = New SegmentableValue(Of Double)( _
              AddressOf SegmentCommandNotification, _
              _model.ListeParametres.Tx_mensEntreeINCINV.Nom, _
              "Taux mensuel d'entrée en INCAP/ INVA à 0 jours")


            m_TablesIncapInvalModele1_Tx = (From elt As IInfoTableReferentiel In _model.Referentiel.InfoTables
                                           Select elt
                                           Where elt.TypeTable = "MAINTINCINV").AsEnumerable
            m_TableIncapInvalModele1_Tx_Selectionne =
                (From e As IInfoTableReferentiel In m_TablesIncapInvalModele1_Tx
                Where e.NomFichier = _model.ListeParametres.Tble_maintien_incinv.ValeurUnique
                Select e).FirstOrDefault()

            m_TablesIncapInvalModel1_Fra = (From elt As IInfoTableReferentiel In _model.Referentiel.InfoTables
                                           Select elt
                                           Where elt.TypeTable = "FRAINCINV").AsEnumerable
            m_TablesIncapInvalModel1_Fra_Selectionne =
               (From e As IInfoTableReferentiel In m_TablesIncapInvalModel1_Fra
                Where e.NomFichier = _model.ListeParametres.tble_maintien_incinvFRA.ValeurUnique
                Select e).FirstOrDefault()

            m_TablesIncapInvalModele2 = (From elt As IInfoTableReferentiel In _model.Referentiel.InfoTables
                                        Select elt
                                        Where elt.TypeTable = "MAINTINCINV_NB_MENS").AsEnumerable
            m_TableIncapInvalModele2_Selectionne =
                (From e As IInfoTableReferentiel In m_TablesIncapInvalModele2
                 Where e.NomFichier = _model.ListeParametres.Tble_maintienINCINVM2.ValeurUnique
                 Select e).FirstOrDefault()


            Title = "GARANTIES INCAP/INVAL"
        End Sub
        Sub New()
        End Sub

#Region "IViewModelTabSection"
        Public Property Icone As String Implements Common.UI.IViewModelTabSection.Icone
        Public Property Title As String Implements Common.UI.IViewModelTabSection.Title
#End Region

        Public Property TablesBCAC As Boolean
            Get
                Return _model.ListeTraitements.TablesBCAC
            End Get
            Set(value As Boolean)
                If value <> _model.ListeTraitements.TablesBCAC Then
                    _model.ListeTraitements.TablesBCAC = value
                    OnPropertyChanged("TablesSpec")
                    OnPropertyChanged("TablesBCAC")
                End If
            End Set
        End Property
        Public Property TablesSpec As Boolean
            Get
                Return Not _model.ListeTraitements.TablesBCAC
            End Get
            Set(value As Boolean)
                If value <> Not _model.ListeTraitements.TablesBCAC Then
                    _model.ListeTraitements.TablesBCAC = Not value
                    OnPropertyChanged("TablesSpec")
                    OnPropertyChanged("TablesBCAC")
                End If
            End Set
        End Property


#Region "Table INCAP / INVAL modèle 1"
        Private m_TableIncapInvalModele1_Tx_Selectionne As IInfoTableReferentiel
        Private m_TablesIncapInvalModele1_Tx As IEnumerable
        Public Property TableIncapInvalModele1Selectionne As IInfoTableReferentiel
            Get
                Return m_TableIncapInvalModele1_Tx_Selectionne
            End Get
            Set(ByVal value As IInfoTableReferentiel)
                If Not value.Equals(m_TableIncapInvalModele1_Tx_Selectionne) Then
                    m_TableIncapInvalModele1_Tx_Selectionne = value
                    _model.ListeParametres.Tble_maintien_incinv.ValeurUnique = m_TableIncapInvalModele1_Tx_Selectionne.NomFichier
                    OnPropertyChanged("TableIncapInvalModele1Selectionne")
                End If
            End Set
        End Property
        Public ReadOnly Property TablesIncapInvalModele1 As IEnumerable
            Get
                Return m_TablesIncapInvalModele1_Tx
            End Get
        End Property
        Public ReadOnly Property TableIncapInvalModele1Utilise As Boolean
            Get
                Return (_model.numMethodeCalculEnCours = 1)
            End Get
        End Property
#End Region

#Region "Table INCAP / INVAL modèle 2"
        Private m_TableIncapInvalModele2_Selectionne As IInfoTableReferentiel
        Private m_TablesIncapInvalModele2 As IEnumerable
        Public Property TableIncapInvalModele2Selectionne As IInfoTableReferentiel
            Get
                Return m_TableIncapInvalModele2_Selectionne
            End Get
            Set(ByVal value As IInfoTableReferentiel)
                If Not value.Equals(m_TableIncapInvalModele2_Selectionne) Then
                    m_TableIncapInvalModele2_Selectionne = value
                    _model.ListeParametres.Tble_maintienINCINVM2.ValeurUnique = value.NomFichier
                    OnPropertyChanged("TableIncapInvalModele2Selectionne")
                End If
            End Set
        End Property
        Public ReadOnly Property TablesIncapInvalModele2 As IEnumerable
            Get
                Return m_TablesIncapInvalModele2
            End Get
        End Property
        Public ReadOnly Property TableIncapInvalModele2Utilise As Boolean
            Get
                Return (_model.numMethodeCalculEnCours = 2)
            End Get
        End Property
#End Region

#Region "Table des abattements liés aux franchises"
        Private m_TablesIncapInvalModel1_Fra_Selectionne As IInfoTableReferentiel
        Private m_TablesIncapInvalModel1_Fra As IEnumerable
        Public Property AbatementsFranchiseSelectionne As IInfoTableReferentiel
            Get
                Return m_TablesIncapInvalModel1_Fra_Selectionne
            End Get
            Set(ByVal value As IInfoTableReferentiel)

                If Not value.Equals(m_TablesIncapInvalModel1_Fra_Selectionne) Then
                    OnPropertyChanging("AbatementsFranchiseSelectionne")
                    m_TablesIncapInvalModel1_Fra_Selectionne = value
                    _model.ListeParametres.tble_maintien_incinvFRA.ValeurUnique = value.NomFichier
                    OnPropertyChanged("AbatementsFranchiseSelectionne")
                End If
            End Set
        End Property
        Public ReadOnly Property TablesAbatementsFranchise As IEnumerable
            Get
                Return m_TablesIncapInvalModel1_Fra
            End Get
        End Property
        Public ReadOnly Property TablesAbattementsFranchise_IsUsed As Boolean
            Get
                Return _model.ListeParametres.tble_maintien_incinvFRA.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Age de fin de la garantie INCAP / INVAL"
        Public Property AgeFinGarantiesIncapInval As Integer
            Get
                Return _model.ListeParametres.Age_FinINCINV.ValeurUnique
            End Get
            Set(ByVal value As Integer)
                OnPropertyChanging("AgeFinGarantiesIncapInval")
                _model.ListeParametres.Age_FinINCINV.ValeurUnique = value
                OnPropertyChanged("AgeFinGarantiesIncapInval")
            End Set
        End Property
        Public ReadOnly Property AgeFinGarantiesIncapInval_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Age_FinINCINV.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property

        Private _AgeFinGarantiesIncapInvalSegmente As SegmentableValue(Of Double)
        Public Property AgeFinGarantiesIncapInvalSegmente As SegmentableValue(Of Double)
            Get
                Return _AgeFinGarantiesIncapInvalSegmente
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("AgeFinGarantiesIncapInvalSegmente")
                _AgeFinGarantiesIncapInvalSegmente = value
                OnPropertyChanged("AgeFinGarantiesIncapInvalSegmente")
            End Set
        End Property
        Public ReadOnly Property AgeFinGarantiesIncapInvalSegmented_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Age_FinINCINV.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Franchises Incap/Inval en nombre de mois"
        Public Property FranchisesIncapEnNombreDeMois As Integer
            Get
                Return _model.ListeParametres.franchise_INCAP.ValeurUnique
            End Get
            Set(ByVal value As Integer)
                OnPropertyChanging("FranchisesIncapEnNombreDeMois")
                _model.ListeParametres.Age_FinINCINV.ValeurUnique = value
                OnPropertyChanged("FranchisesIncapEnNombreDeMois")
            End Set
        End Property
        Public ReadOnly Property FranchisesIncapInvalEnNombreDeMois_IsUsed As Boolean
            Get
                Return _model.ListeParametres.franchise_INCAP.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Abattement maladies non objectivables"
        Private _AbattementMaladiesNonObjectivables As SegmentableValue(Of Double)
        Public Property AbattementMaladiesNonObjectivables As SegmentableValue(Of Double)
            Get
                Return _AbattementMaladiesNonObjectivables
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("AbattementMaladiesNonObjectivables")
                _AbattementMaladiesNonObjectivables = value
                OnPropertyChanged("AbattementMaladiesNonObjectivables")
            End Set
        End Property
        Public ReadOnly Property AbattementMaladiesNonObjectivables_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Tx_abat_MalaNonObje.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Abattement exclusion perte de revenus"
        Private _AbattementExclusionPerteRevenus As SegmentableValue(Of Double)
        Public Property AbattementExclusionPerteRevenus As SegmentableValue(Of Double)
            Get
                Return _AbattementExclusionPerteRevenus
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("AbattementExclusionPerteRevenus")
                _AbattementExclusionPerteRevenus = value
                OnPropertyChanged("AbattementExclusionPerteRevenus")
            End Set
        End Property
        Public ReadOnly Property AbattementExclusionPerteRevenus_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Tx_abat_ExclPerteRev.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Majoration prudentielle (marge technique) des sinistres INCAP / INVAL"
        Private _MajorationPrudentielle As SegmentableValue(Of Double)
        Public Property MajorationPrudentielle As SegmentableValue(Of Double)
            Get
                Return _MajorationPrudentielle
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("MajorationPrudentielle")
                _MajorationPrudentielle = value
                OnPropertyChanged("MajorationPrudentielle")
            End Set
        End Property
        Public ReadOnly Property MajorationPrudentielle_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Tx_MajoPrudSinINCINV.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Chargement de sécurité lié aux incertitudes sur la table de maintien en sinistre incap / Inval"
        Private _ChargementDeSecurite As SegmentableValue(Of Double)
        Public Property ChargementDeSecurite As SegmentableValue(Of Double)
            Get
                Return _ChargementDeSecurite
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("ChargementDeSecurite")
                _ChargementDeSecurite = value
                OnPropertyChanged("ChargementDeSecurite")
            End Set
        End Property
        Public ReadOnly Property ChargementDeSecurite_IsUsed As Boolean
            Get
                Return _model.ListeParametres.Tx_chgtSecuINCINV.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Taux mensuel d'entrée en INCAP / INVAL"
        Private _TauxMensuelEntreeEnIncapacite As SegmentableValue(Of Double)
        Public Property TauxMensuelEntreeEnIncapacite As SegmentableValue(Of Double)
            Get
                Return _TauxMensuelEntreeEnIncapacite
            End Get
            Set(ByVal value As SegmentableValue(Of Double))
                OnPropertyChanging("TauxMensuelEntreeEnIncapacite")
                _TauxMensuelEntreeEnIncapacite = value
                OnPropertyChanged("TauxMensuelEntreeEnIncapacite")
            End Set
        End Property
        Public ReadOnly Property TauxMensuelEntreeEnIncapacite_IsUSed As Boolean
            Get
                Return _model.ListeParametres.Tx_mensEntreeINCINV.Methode_Cal(_model.numMethodeCalculEnCours - 1)
            End Get
        End Property
#End Region

#Region "Segment"


        Private _CurrentSegmentableValue As Object
        Public Property CurrentSegmentableValue As Object
            Get
                Return _CurrentSegmentableValue
            End Get
            Set(ByVal value As Object)
                OnPropertyChanging("CurrentSegmentableValue")
                _CurrentSegmentableValue = value
                OnPropertyChanged("CurrentSegmentableValue")
            End Set
        End Property

        Private Sub SegmentCommandNotification(ByVal sender As Object, ByVal param As Object)
            CurrentSegmentableValue = sender
        End Sub
#End Region

    End Class
End Namespace
